local ComponentManager={}--从Component角度对entity中的Component进行操作
function ComponentManager.addComponent(Entity,Component)--添加
  assert(Entity~=nil,"no Entity exist")
  assert(Component~=nil, "invalid input")
  for _,traverseComponent in ipairs(Entity.Components) do
    -- 如果world的Components已经有该元素，则返回false
    if(Component==traverseComponent) then
      return false
      end
  end
  Component.isComponent=true
  table.insert(Entity.Components,Component)
  return true
end

function ComponentManager.deleteComponent(Entity,Component)--删除
  assert(Entity~=nil,"no Entity exist")
  assert(Component~=nil,"invalid input")
  local pos=0
  for i,traverseComponent in ipairs(Entity.Components) do
    -- 如果有这个元素则删掉，没有则返回false
    if(Component==traverseComponent) then
      pos=i
    end
  end
  if(pos==0) then
    return false
  end
  table.remove(Entity.Components,pos)
  return true
end

function ComponentManager.checkComponent(Entity,Component)--查
  assert(Entity~=nil, "no Entity exist")
  assert(Component~=nil, "invalid input")
  if(Entity.Components.Component~=nil) then
    return true
  end
  return false
end
return ComponentManager